package xinxin.com.IteratorPatternBasic.Aggregate;

import xinxin.com.IteratorPatternBasic.Iterator.Iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/3/29 9:41
 */
public class ConcreteAggregate extends Aggregate {
    private List<Object> objectList;
    int count;

    public ConcreteAggregate(int count) {
        this.objectList = new ArrayList<Object>();
        this.count = count;
        while (0 != count--) {
            this.objectList.add(new Object());
        }
    }

    @Override
    public Iterator CreateIterator() {
        return null;
    }

    public int getCount() {
        return count;
    }

    public void set(int index, Object object) {
        this.objectList.set(index, object);
    }

    public Object get(int index) {
        return objectList.get(index);
    }
}
